package com.admin.common.util;

import java.util.Arrays;
import java.util.Map;

/**
 * 订单支付方式
 * 
 * @author zhangyang
 * @date 2019/05/14
 */
public class YsOrderPayTypeUtils {

    /**
     * 支付方式兼容搜索
     *
     * 有些支付方式，因为没有order_pay_type存时没有区分开来，所以搜索时要兼容处理
     * 
     * @param orderPayType
     * @return
     */
    public static Map<String, Object> getLianlianPayType(String orderPayType) {
        Map<String, Object> params = YsCollectionUtil.createHashMap();
        if ("creditCard".equalsIgnoreCase(orderPayType)) {
            // 信用卡支付
            params.put("orderPayType", "card");
            params.put("lianlianPayType", "AGRT_CREDIT_CARD");
        } else if ("card".equalsIgnoreCase(orderPayType)) {
            // 储蓄卡支付
            params.put("orderPayType", "card");
            params.put("lianlianPayType", "AGRT_DEBIT_CARD");
        } else if ("ebank".equalsIgnoreCase(orderPayType)) {
            // 个人网银
            params.put("orderPayType", "ebank");
            params.put("lianlianPayTypes", Arrays.asList("EBANK_DEBIT_CARD", "EBANK_CREDIT_CARD"));
        } else if ("b2b_ebank".equalsIgnoreCase(orderPayType)) {
            // 企业网银
            params.put("orderPayType", "ebank");
            params.put("lianlianPayType", "EBANK_B2B");
        } else if ("balance".equalsIgnoreCase(orderPayType)) {
            // 个人钱包
            params.put("orderPayType", "balance");
            params.put("payAccountType", 0);
        } else if ("b2b_balance".equalsIgnoreCase(orderPayType)) {
            // 企业钱包
            params.put("orderPayType", "balance");
            params.put("payAccountType", 1);
        } else {
            params.put("orderPayType", orderPayType);
        }
        return params;
    }

    /**
     * 支付方式
     * 
     * @param orderPayType
     * @param lianlianPayType
     * @param payAccountType
     * @return
     */
    public static String getSupportOrderPayType(String orderPayType, String lianlianPayType, Integer payAccountType) {
        if ("card".equalsIgnoreCase(orderPayType) && "AGRT_CREDIT_CARD".equalsIgnoreCase(lianlianPayType)) {
            // 信用卡
            return "creditCard";
        } else if ("card".equalsIgnoreCase(orderPayType) && "AGRT_DEBIT_CARD".equalsIgnoreCase(lianlianPayType)) {
            // 储蓄卡
            return "card";
        } else if ("ebank".equalsIgnoreCase(orderPayType) && ("EBANK_DEBIT_CARD".equalsIgnoreCase(lianlianPayType)
            || "EBANK_CREDIT_CARD".equalsIgnoreCase(lianlianPayType))) {
            // 个人网银
            return "ebank";
        } else if ("ebank".equalsIgnoreCase(orderPayType) && "EBANK_B2B".equalsIgnoreCase(lianlianPayType)) {
            // 企业网银
            return "b2b_ebank";
        } else if ("balance".equalsIgnoreCase(orderPayType) && payAccountType != null && 0 == payAccountType) {
            // 个人钱包
            return "balance";
        } else if ("balance".equalsIgnoreCase(orderPayType) && payAccountType != null && 1 == payAccountType) {
            // 企业钱包
            return "b2b_balance";
        } else {
            return orderPayType;
        }
    }

}
